home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 January: Mac OS SDK / Dev.CD Jan 00 SDK1.toast / Development Kits / Mac OS / QuickTime / QuickTime 3 Interfaces & Libs / QTDevWin / CIncludes / OSUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-21  |  11.4 KB  |  438 lines  |  [TEXT/dosa]

  1. /*
  2.      File:        OSUtils.h
  3.  
  4.      Contains:    OS Utilities Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    QuickTime 3.0
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __OSUTILS__
  19. #define __OSUTILS__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. /*  HandToHand and other memory utilties were moved to MacMemory.h */
  28. #ifndef __MACMEMORY__
  29. #include <MacMemory.h>
  30. #endif
  31. /*  GetTrapAddress and other trap table utilties were moved to Patches.h */
  32. #ifndef __PATCHES__
  33. #include <Patches.h>
  34. #endif
  35. /*  Date and Time utilties were moved to DateTimeUtils.h */
  36. #ifndef __DATETIMEUTILS__
  37. #include <DateTimeUtils.h>
  38. #endif
  39. #if !TARGET_OS_MAC
  40. #ifndef __ENDIAN__
  41. #include <Endian.h>
  42. #endif
  43. #endif  /*  !TARGET_OS_MAC */
  44.  
  45.  
  46.  
  47. #if PRAGMA_ONCE
  48. #pragma once
  49. #endif
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54.  
  55. #if PRAGMA_IMPORT
  56. #pragma import on
  57. #endif
  58.  
  59. #if PRAGMA_STRUCT_ALIGN
  60.     #pragma options align=mac68k
  61. #elif PRAGMA_STRUCT_PACKPUSH
  62.     #pragma pack(push, 2)
  63. #elif PRAGMA_STRUCT_PACK
  64.     #pragma pack(2)
  65. #endif
  66.  
  67.  
  68. enum {
  69.     useFree                        = 0,
  70.     useATalk                    = 1,
  71.     useAsync                    = 2,
  72.     useExtClk                    = 3,                            /*Externally clocked*/
  73.     useMIDI                        = 4
  74. };
  75.  
  76.  
  77. enum {
  78.     false32b                    = 0,                            /*24 bit addressing error*/
  79.     true32b                        = 1                                /*32 bit addressing error*/
  80. };
  81.  
  82.  
  83. enum {
  84.                                                                 /* result types for RelString Call */
  85.     sortsBefore                    = -1,                            /*first string < second string*/
  86.     sortsEqual                    = 0,                            /*first string = second string*/
  87.     sortsAfter                    = 1                                /*first string > second string*/
  88. };
  89.  
  90.  
  91. enum {
  92.     dummyType                    = 0,
  93.     vType                        = 1,
  94.     ioQType                        = 2,
  95.     drvQType                    = 3,
  96.     evType                        = 4,
  97.     fsQType                        = 5,
  98.     sIQType                        = 6,
  99.     dtQType                        = 7,
  100.     nmType                        = 8
  101. };
  102.  
  103. typedef SignedByte                         QTypes;
  104.  
  105. struct SysParmType {
  106.     UInt8                             valid;
  107.     UInt8                             aTalkA;
  108.     UInt8                             aTalkB;
  109.     UInt8                             config;
  110.     short                             portA;
  111.     short                             portB;
  112.     long                             alarm;
  113.     short                             font;
  114.     short                             kbdPrint;
  115.     short                             volClik;
  116.     short                             misc;
  117. };
  118. typedef struct SysParmType                SysParmType;
  119.  
  120. typedef SysParmType *                    SysPPtr;
  121.  
  122. struct QElem {
  123.     struct QElem *                    qLink;
  124.     short                             qType;
  125.     short                             qData[1];
  126. };
  127. typedef struct QElem                    QElem;
  128. typedef QElem *                            QElemPtr;
  129. #if TARGET_OS_MAC
  130.  
  131. struct QHdr {
  132.     short                             qFlags;
  133.     QElemPtr                         qHead;
  134.     QElemPtr                         qTail;
  135. };
  136. typedef struct QHdr                        QHdr;
  137. typedef QHdr *                            QHdrPtr;
  138. #else
  139. /*
  140.    QuickTime 3.0:
  141.    this version of QHdr contains the Mutex necessary for
  142.    non-mac non-interrupt code
  143. */
  144.  
  145. struct QHdr {
  146.     short                             qFlags;
  147.     short                             pad;
  148.     long                             MutexID;
  149.     QElemPtr                         qHead;
  150.     QElemPtr                         qTail;
  151. };
  152. typedef struct QHdr                        QHdr;
  153. typedef QHdr *                            QHdrPtr;
  154. #endif  /* TARGET_OS_MAC */
  155.  
  156.  
  157.  
  158. typedef CALLBACK_API( void , DeferredTaskProcPtr )(long dtParam);
  159. /*
  160.     WARNING: DeferredTaskProcPtr uses register based parameters under classic 68k
  161.              and cannot be written in a high-level language without 
  162.              the help of mixed mode or assembly glue.
  163. */
  164. typedef REGISTER_UPP_TYPE(DeferredTaskProcPtr)                     DeferredTaskUPP;
  165. enum { uppDeferredTaskProcInfo = 0x0000B802 };                     /* register no_return_value Func(4_bytes:A1) */
  166. #define NewDeferredTaskProc(userRoutine)                         (DeferredTaskUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDeferredTaskProcInfo, GetCurrentArchitecture())
  167. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  168.     #pragma parameter CallDeferredTaskProc(__A0, __A1)
  169.     void CallDeferredTaskProc(DeferredTaskUPP routine, long dtParam) = 0x4E90;
  170. #else
  171.     #define CallDeferredTaskProc(userRoutine, dtParam)             CALL_ONE_PARAMETER_UPP((userRoutine), uppDeferredTaskProcInfo, (dtParam))
  172. #endif
  173.  
  174. struct DeferredTask {
  175.     QElemPtr                         qLink;
  176.     short                             qType;
  177.     short                             dtFlags;
  178.     DeferredTaskUPP                 dtAddr;
  179.     long                             dtParam;
  180.     long                             dtReserved;
  181. };
  182. typedef struct DeferredTask                DeferredTask;
  183. typedef DeferredTask *                    DeferredTaskPtr;
  184. #if TARGET_OS_MAC
  185.  
  186. struct MachineLocation {
  187.     Fract                             latitude;
  188.     Fract                             longitude;
  189.     union {
  190.         SInt8                             dlsDelta;                /* signed byte; daylight savings delta */
  191.         long                             gmtDelta;                /* use low 24-bits only */
  192.     }                                 u;
  193. };
  194. typedef struct MachineLocation            MachineLocation;
  195. #else
  196. /*
  197.     QuickTime 3.0:
  198.     Alignment of MachineLocation is weird. The union above used for delta
  199.     tends not to work on non-Mac compilers.
  200. */
  201.  
  202. struct MachineLocation {
  203.     Fract                             latitude;
  204.     Fract                             longitude;
  205.     BigEndianLong                     delta;                        /* high byte is daylight savings delta, low 24-bits is GMT delta */
  206. };
  207. typedef struct MachineLocation            MachineLocation;
  208. #endif  /* TARGET_OS_MAC */
  209.  
  210. EXTERN_API( Boolean )
  211. IsMetric                        (void)                                                        THREEWORDINLINE(0x3F3C, 0x0004, 0xA9ED);
  212.  
  213. EXTERN_API( SysPPtr )
  214. GetSysPPtr                        (void)                                                        THREEWORDINLINE(0x2EBC, 0x0000, 0x01F8);
  215.  
  216.  
  217. /*
  218.     NOTE: SysBeep() has been moved to Sound.h.  
  219.           We could not automatically #include Sound.h in this file
  220.           because Sound.h indirectly #include's OSUtils.h which
  221.           would make a circular include.
  222. */
  223.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  224.                                                                                             #pragma parameter __D0 DTInstall(__A0)
  225.                                                                                             #endif
  226. EXTERN_API( OSErr )
  227. DTInstall                        (DeferredTaskPtr         dtTaskPtr)                            ONEWORDINLINE(0xA082);
  228.  
  229.  
  230.  
  231. #if TARGET_CPU_PPC || !TARGET_OS_MAC
  232. #define GetMMUMode() ((SInt8)true32b)
  233. #define SwapMMUMode(x) (*(SInt8*)(x) = true32b)
  234. #else
  235. EXTERN_API( SInt8 )
  236. GetMMUMode                        (void)                                                        TWOWORDINLINE(0x1EB8, 0x0CB2);
  237.  
  238.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  239.                                                                                             #pragma parameter SwapMMUMode(__A0)
  240.                                                                                             #endif
  241. EXTERN_API( void )
  242. SwapMMUMode                        (SInt8 *                mode)                                THREEWORDINLINE(0x1010, 0xA05D, 0x1080);
  243.  
  244. #endif
  245.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  246.                                                                                             #pragma parameter Delay(__A0, __A1)
  247.                                                                                             #endif
  248. EXTERN_API( void )
  249. Delay                            (unsigned long             numTicks,
  250.                                  unsigned long *        finalTicks)                            TWOWORDINLINE(0xA03B, 0x2280);
  251.  
  252.  
  253. EXTERN_API( OSErr )
  254. WriteParam                        (void);
  255.  
  256.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  257.                                                                                             #pragma parameter Enqueue(__A0, __A1)
  258.                                                                                             #endif
  259. EXTERN_API( void )
  260. Enqueue                            (QElemPtr                 qElement,
  261.                                  QHdrPtr                 qHeader)                            ONEWORDINLINE(0xA96F);
  262.  
  263.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  264.                                                                                             #pragma parameter __D0 Dequeue(__A0, __A1)
  265.                                                                                             #endif
  266. EXTERN_API( OSErr )
  267. Dequeue                            (QElemPtr                 qElement,
  268.                                  QHdrPtr                 qHeader)                            ONEWORDINLINE(0xA96E);
  269.  
  270.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  271.                                                                                             #pragma parameter __D0 SetCurrentA5
  272.                                                                                             #endif
  273. EXTERN_API( long )
  274. SetCurrentA5                    (void)                                                        THREEWORDINLINE(0x200D, 0x2A78, 0x0904);
  275.  
  276.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  277.                                                                                             #pragma parameter __D0 SetA5(__D0)
  278.                                                                                             #endif
  279. EXTERN_API( long )
  280. SetA5                            (long                     newA5)                                ONEWORDINLINE(0xC18D);
  281.  
  282.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  283.                                                                                             #pragma parameter __D0 InitUtil
  284.                                                                                             #endif
  285. EXTERN_API( OSErr )
  286. InitUtil                        (void)                                                        ONEWORDINLINE(0xA03F);
  287.  
  288.  
  289. #if TARGET_CPU_PPC
  290. EXTERN_API( void )
  291. MakeDataExecutable                (void *                    baseAddress,
  292.                                  unsigned long             length);
  293.  
  294. #endif  /* TARGET_CPU_PPC */
  295.  
  296. #if TARGET_CPU_68K
  297. EXTERN_API( Boolean )
  298. SwapInstructionCache            (Boolean                 cacheEnable);
  299.  
  300. EXTERN_API( void )
  301. FlushInstructionCache            (void)                                                        TWOWORDINLINE(0x7001, 0xA098);
  302.  
  303. EXTERN_API( Boolean )
  304. SwapDataCache                    (Boolean                 cacheEnable);
  305.  
  306. EXTERN_API( void )
  307. FlushDataCache                    (void)                                                        TWOWORDINLINE(0x7003, 0xA098);
  308.  
  309. EXTERN_API( void )
  310. FlushCodeCache                    (void)                                                        ONEWORDINLINE(0xA0BD);
  311.  
  312.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  313.                                                                                             #pragma parameter __D0 FlushCodeCacheRange(__A0, __A1)
  314.                                                                                             #endif
  315. EXTERN_API( OSErr )
  316. FlushCodeCacheRange                (void *                    address,
  317.                                  unsigned long             count)                                TWOWORDINLINE(0x7009, 0xA098);
  318.  
  319. #endif  /* TARGET_CPU_68K */
  320.  
  321.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  322.                                                                                             #pragma parameter ReadLocation(__A0)
  323.                                                                                             #endif
  324. EXTERN_API( void )
  325. ReadLocation                    (MachineLocation *        loc)                                FOURWORDINLINE(0x203C, 0x000C, 0x00E4, 0xA051);
  326.  
  327.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  328.                                                                                             #pragma parameter WriteLocation(__A0)
  329.                                                                                             #endif
  330. EXTERN_API( void )
  331. WriteLocation                    (const MachineLocation * loc)                                FOURWORDINLINE(0x203C, 0x000C, 0x00E4, 0xA052);
  332.  
  333.  
  334.  
  335. #if OLDROUTINENAMES
  336. #define IUMetric() IsMetric()
  337. #endif  /* OLDROUTINENAMES */
  338.  
  339. /*
  340.     NOTE: SysEnvirons is obsolete.  You should be using Gestalt.
  341. */
  342. /* Environs Equates */
  343.  
  344. enum {
  345.     curSysEnvVers                = 2                                /*Updated to equal latest SysEnvirons version*/
  346. };
  347.  
  348.  
  349. struct SysEnvRec {
  350.     short                             environsVersion;
  351.     short                             machineType;
  352.     short                             systemVersion;
  353.     short                             processor;
  354.     Boolean                         hasFPU;
  355.     Boolean                         hasColorQD;
  356.     short                             keyBoardType;
  357.     short                             atDrvrVersNum;
  358.     short                             sysVRefNum;
  359. };
  360. typedef struct SysEnvRec                SysEnvRec;
  361.  
  362. enum {
  363.                                                                 /* Machine Types */
  364.     envMac                        = -1,
  365.     envXL                        = -2,
  366.     envMachUnknown                = 0,
  367.     env512KE                    = 1,
  368.     envMacPlus                    = 2,
  369.     envSE                        = 3,
  370.     envMacII                    = 4,
  371.     envMacIIx                    = 5,
  372.     envMacIIcx                    = 6,
  373.     envSE30                        = 7,
  374.     envPortable                    = 8,
  375.     envMacIIci                    = 9,
  376.     envMacIIfx                    = 11
  377. };
  378.  
  379.  
  380. enum {
  381.                                                                 /* CPU types */
  382.     envCPUUnknown                = 0,
  383.     env68000                    = 1,
  384.     env68010                    = 2,
  385.     env68020                    = 3,
  386.     env68030                    = 4,
  387.     env68040                    = 5
  388. };
  389.  
  390.  
  391. enum {
  392.                                                                 /* Keyboard types */
  393.     envUnknownKbd                = 0,
  394.     envMacKbd                    = 1,
  395.     envMacAndPad                = 2,
  396.     envMacPlusKbd                = 3,
  397.     envAExtendKbd                = 4,
  398.     envStandADBKbd                = 5,
  399.     envPrtblADBKbd                = 6,
  400.     envPrtblISOKbd                = 7,
  401.     envStdISOADBKbd                = 8,
  402.     envExtISOADBKbd                = 9
  403. };
  404.  
  405.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  406.                                                                                             #pragma parameter __D0 SysEnvirons(__D0, __A0)
  407.                                                                                             #endif
  408. EXTERN_API( OSErr )
  409. SysEnvirons                        (short                     versionRequested,
  410.                                  SysEnvRec *            theWorld)                            ONEWORDINLINE(0xA090);
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418. #if PRAGMA_STRUCT_ALIGN
  419.     #pragma options align=reset
  420. #elif PRAGMA_STRUCT_PACKPUSH
  421.     #pragma pack(pop)
  422. #elif PRAGMA_STRUCT_PACK
  423.     #pragma pack()
  424. #endif
  425.  
  426. #ifdef PRAGMA_IMPORT_OFF
  427. #pragma import off
  428. #elif PRAGMA_IMPORT
  429. #pragma import reset
  430. #endif
  431.  
  432. #ifdef __cplusplus
  433. }
  434. #endif
  435.  
  436. #endif /* __OSUTILS__ */
  437.  
  438.